// SAMPLE: Generate text from a simple prompt
// GUIDANCE: Instructions to run this code: https://aka.ms/oai/net/start
#:package OpenAI@2.*
#:property PublishAot=false

using OpenAI.Chat;

string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ChatClient client = new("gpt-4.1", key);
ChatCompletion acompletion = client.CompleteChat("Write a one-sentence bedtime story about a unicorn.");
Console.WriteLine(acompletion.Content[0].Text);